package com.tb.utils;

import java.util.Random;

/**
 * 生成随机盐的工具类
 */
public class SaltUtils {

    public static String getSalt(int count) {
        char[] s = "ABCDEFGHIJKMLNOPQRSTUVWXYZabcdefghijkmlnopqrstuvwxyz!@#$%^&*()-+".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < count; i++) {
            int index = new Random().nextInt(s.length);
            sb.append(s[index]);
        }
        return sb.toString();

    }

//    public static void main(String[] args) {
//
//            String salt = getSalt(8);
//            Md5Hash hash = new Md5Hash("juyou", salt, 1024);
//            String s = hash.toHex();
//            System.out.println(salt);
//            System.out.println(s);
//
//    }

}
